package work.sajor.wechatpush.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import work.sajor.wechatpush.service.Pusher;

import java.util.HashMap;
import java.util.Map;

/**
 *@ClassName JobWorker
 *@Description TODO
 *@Description TODO
 *@Author ysg
 *@Date 2024/6/2 16:00
 * 这个是晚上微信推送的的模板
 */
@Component
public class JobWorkerNight {
    /**
     * 要推送的用户openid
     */

    @Autowired
    Pusher pusherService;

    @Scheduled(cron = "0 30 23 * * ?")  //每天的23点0
    public void goodMorning() throws InterruptedException {
   Map<String,String> HashCityMap=new HashMap<>();
        HashCityMap.put("o1CxZ6gURbhRpTTe1pwgc","重庆市");
        HashCityMap.put("o1CxZ6m7zsr_CNeMDrBByc","苏州市");
        HashCityMap.put("o1CxZ6pFH8byx_kRjvRxB-Qk","嘉兴市");
        HashCityMap.put("o1CxZ6mtr7IC2OLVPhUl6s","马鞍山市");
        HashCityMap.put("o1CxZ6zYKhnx8qfPyYWNLN4","重庆市");
        HashCityMap.put("o1CxZR4rFHZoycvRyol20jA","上海市");
        HashCityMap.forEach((openId1,querycity)->{{
            try {
                Thread.sleep(30000); // 休眠30秒
                pusherService.pushNight(openId1,querycity);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }});
    }
}
